//
//  CropView.h
//  OpenGLGame
//
//  Created by Nguyen Cong Huy on 5/2/13.
//  Copyright (c) 2013 UIT. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol CropViewDelegate;

@interface CropView : UIView{
    UIImageView* topArrow;
    UIImageView* leftArrow;
    UIImageView* bottomArrow;
    UIImageView* rightArrow;
    
    UIView* cropView;           // view to draw crop view
    UIView* topView;            // view to fill other area not in crop area
    UIView* bottomView;
    UIView* leftView;
    UIView* rightView;
    
    float ratio;                // width/height crop area
    float scale;
    
    CGRect imageRect;
    CGSize minCropSize;
    CGRect cropRect;
    CGRect oldCropRect;
    
    bool isEnableCrop;
    float padding;
    
    UIView* view;               // view are dragging (4 arrow)
    
    id<CropViewDelegate> delegate;
    UIImageView* imageView;
    
}

- (id)initWithFrame:(CGRect)frame padding:(float)_padding cropRatio:(float)_ratio topBottomArrowImage:(UIImage*)topBottomImage leftRightArrowImage:(UIImage*) leftRightImage arrowSize:(float)arrowSize;
- (void) setCropFrame:(CGRect)cropFrame;
- (void) updateView;
- (void) setImage:(UIImage*)image;
- (UIImage*) image;
- (CGRect) getNormalizeCropRect;
- (void) setNormalizeCropRect:(CGRect)cropRect withStep:(int)step;    // direction 0, 1, 2, 3: 0 is normal direction; 1, 2, 3 is rotate image to counter clock wise.


@property (nonatomic, assign) CGSize minCropSize;
@property (nonatomic, readonly) CGRect cropRect;
@property (nonatomic, readonly) CGRect imageRect;
@property (nonatomic, readonly) float scale;
@property (nonatomic, assign) bool isEnableCrop;
@property (nonatomic, assign) float ratio;
@property (nonatomic, retain) id<CropViewDelegate> delegate;

@end


@protocol CropViewDelegate <NSObject>

@optional
- (void)cropViewDidChangeCropSize:(CropView*)cropView isFullImage:(bool)isFull;

@end
